﻿#region

using System.Drawing.Imaging;
using System.IO;

#endregion

namespace PicSizer.Program.Logic.Compress
{
    public class Jpeg : CompressItem
    {
        /// <summary>`
        /// 图像编码信息
        /// </summary>
        private EncoderParameters _encoderParameters = new EncoderParameters();

        public Jpeg(string imgPath, string outputFilename)
        {
            this.Init(imgPath, outputFilename);
        }

        protected override void WriteToStreamWithQuality(Stream stream, int quality)
        {
            this._encoderParameters.Param[0] = Encoder.GetParameter(quality);
            this.Img.Save(stream, Encoder.InfoJpeg, this._encoderParameters);
        }
    }
}